#include "StdAfx.h"
#include "Storage.h"
#include "Aggregator.h"

//////////////////////////////////////////////////////////////////////////
void Storage::Add(const AggregatorPtr& i_aggr)
{
	PartsList parts = i_aggr->GetParts();

	for(PartsList::const_iterator it = parts.begin(); it != parts.end(); ++it)
	{
		const Signature& signature = (*it)->GetSignature();
		for(Signature::const_iterator it2 = signature.begin(); it2 != signature.end(); ++it2)
		{
			m_parts[*it2].push_back(*it);
		}
	}
   m_aggr.push_back(i_aggr);
}

//////////////////////////////////////////////////////////////////////////
size_t Storage::size() const
{
   return m_aggr.size();
}

//////////////////////////////////////////////////////////////////////////
PartsList Storage::GetParts(int i_signaturePart) const
{
   PartsIdx::const_iterator it = m_parts.find(i_signaturePart);
   return it == m_parts.end() ? PartsList() : it->second;
}